
public class P40 {
	public static void main(String[] args) {
		StringBuffer buffer = new StringBuffer();
		
		int count = 1;
		int multiple = 1;
		
		for (int i = 1; true; i++) {
			buffer.append(i);
			
			int position = (int)Math.pow(10, count - 1); 
			if (buffer.length() >= position) {
				count++;				
				int n = Integer.parseInt(buffer.substring(position - 1, position));
				System.out.println(n);
				multiple *= n;
			}
			
			if (position == 1000000) {
				break;
			}
		}
		
		System.out.println(multiple);
	}
}
